/*
 * I write in my free time, for personal using
 * when i fell proud of it, i will give it to public
 * now,have nothing more to say
 */
package com.quangtin3.run;

import com.quangtin3.utils.SelfRunnable;
import com.quangtin3.utils.TunllLogger;
import java.io.IOException;

/**
 *
 * @author quanghx
 */
public class TestSelfRunnable extends SelfRunnable {

    public TestSelfRunnable(boolean bstart) {
        super(bstart);
    }

    @Override
    protected void elmProcess() throws InterruptedException {
        TunllLogger.sys.debug("elmProcess wake up at " + System.currentTimeMillis());
        Thread.sleep(300);
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        TunllLogger.sys.debug("main thread start");
        TestSelfRunnable test = new TestSelfRunnable(true);

        for (int i = 0; i < 100; i++) {
            Thread.sleep(100);
            switch (i % 4) {
                case 0:
                    test.requestStart();
                    break;
                case 1:
                    test.requestResume();
                    break;
                case 2:
                    test.requestSuspend();
                    break;
                case 3:
                    Thread.sleep(i*7);
                    break;
            }
        }
        TunllLogger.sys.debug("main thread request stop");
        test.requestStop();
        TunllLogger.sys.debug("main thread end");
//        int i;
//        do {
//            System.out.print("read i=");
//            i = System.in.read();
//            System.out.println("process value i " + i);
//            switch(i){
//                case 13:
//                    break;
//                case 34:
//                    break;
//                default:
//                    break;
//            }
//
//        } while (i > -1);
    }
}
